import {lazy,Suspense} from 'react';
import { Navigate } from 'react-router-dom';
import Loading from './Loading'
// 引入 布局页面
let Index = lazy(()=>import("../views/layout"));
// 引入登录页面
let Login = lazy(()=>import('../views/login'));
// 引入用户列表页面
let Users = lazy(()=>import('../views/users'));
// 引入权限列表 
let Rights = lazy(()=>import('../views/rights'));
let Roles = lazy(()=>import("../views/roles"));
let Goods = lazy(()=>import("../views/Goods"));
let Params = lazy(()=>import("../views/params"));
let Cate = lazy(()=>import("../views/categories"));
let Orders = lazy(()=>import("../views/orders"));
let Reports = lazy(()=>import("../views/reports"))
let Home = lazy(()=>import("../views/home"))
let NotFound = lazy(()=>import("../views/notfound"))
let AddGoods = lazy(()=>import('../views/addgoods'))
let element:RouterObject[] = [
    {
        path:'/index',
        element:<Suspense fallback={<Loading/>}><Index/></Suspense>,
        author:true,
        children:[
            {
                path:'users',
                element:<Suspense fallback={<Loading/>}><Users/></Suspense>,
                author:true
            },
            {
                path:'roles',
                element:<Suspense fallback={<Loading/>}><Roles/></Suspense>,
                author:true
            },
            {
                path:'rights',
                element:<Suspense fallback={<Loading/>}><Rights/></Suspense>,
                author:true
            },
            {
                path:'goods',
                element:<Suspense fallback={<Loading/>}><Goods/></Suspense>,
                author:true
            },
            {
                path:'params',
                element:<Suspense fallback={<Loading/>}><Params/></Suspense>,
                author:true
            },
            {
                path:'categories',
                element:<Suspense fallback={<Loading/>}><Cate/></Suspense>,
                author:true
            },{
                path:'orders',
                element:<Suspense fallback={<Loading/>}><Orders/></Suspense>,
                author:true
            },{
                path:'reports',
                element:<Suspense fallback={<Loading/>}><Reports/></Suspense>,
                author:true
            },{
                path:"home",
                element:<Suspense fallback={<Loading/>}><Home/></Suspense>,
                author:true
            },{
                path:"addGoods",
                element:<Suspense fallback={<Loading></Loading>}><AddGoods></AddGoods></Suspense>,
                author:true
            }
        ]
    },
    {
        path:'/login',
        element:<Suspense fallback={<Loading/>}><Login/></Suspense>,
        author:false
    },
    {
        path:"/",
        element:<Navigate to='/index/home'></Navigate>,
        author:false
    },{
        path:"*",
        element:<Suspense fallback={<Loading/>}><NotFound/></Suspense>,
        author:false
    }
]

export default element;